const boxElements = document.getElementsByClassName("box");
const box_1 = boxElements[0];
const box_2 = boxElements[1];
const box_3 = boxElements[2];

function moveBox(element) {
    // 移动到左侧
    element.style.left = "-130%";
    // 设置过渡效果
    element.style.transition = "left 5s";

    // 等待一段时间后，移动到右侧
    setTimeout(() => {
        element.style.left = "120%";
        // 移除过渡效果
        element.style.transition = "left 0s";
        // 再次调用函数形成循环
        setTimeout(() => moveBox(element), 200);
    }, 4500);
}

// 分别调用moveBox函数，设置不同的延迟时间
setTimeout(() => moveBox(box_1), 2000);
setTimeout(() => moveBox(box_2), 3700);
setTimeout(() => moveBox(box_3), 4800);
